﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Project01
{
    class GasTank:Object
    {
        private Vector2 carLocation;
        public Vector2 CarLocation
        {
            get { return carLocation; }
            set { carLocation = value; }
        }

        public GasTank(Vector2 dimension, Vector2 location, int mass, GraphicsDevice graphicDevice)
            : base(dimension, location, mass, graphicDevice)
        {
            ObjTexture = CreateRectangle((int)dimension.X, (int)dimension.Y, Color.Brown);
        }

        public void Update(InputListener inputListener)
        {
            if (inputListener.isKeyPressed(Keys.J) && Location.X > CarLocation.X)
            {
                Position -= new Vector2(10, 0);
                Location -= new Vector2(10, 0);
                XCoorPosition -= new Vector2(10, 0);
                YCoorPosition -= new Vector2(10, 0);
            }
            if (inputListener.isKeyPressed(Keys.L) && Location.X < CarLocation.X + 60)
            {
                Position += new Vector2(10, 0);
                Location += new Vector2(10, 0);
                XCoorPosition += new Vector2(10, 0);
                YCoorPosition += new Vector2(10, 0);
            }
            if (inputListener.isKeyPressed(Keys.I) && Mass < 200)
                    Mass += 10;
            if (inputListener.isKeyPressed(Keys.K))// && Mass > 100)
                    Mass -= 10;            
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(ObjTexture, Location, Color.White);
            spriteBatch.Draw(XCoordinate, XCoorPosition, Color.White);
            spriteBatch.Draw(YCoordinate, YCoorPosition, Color.White);
        }
    }
}
